<?php error_reporting(0);
session_start(); 
if (isset($_SESSION['connect'])) {

?>
<LINK HREF="style.css" REL="stylesheet" TYPE="text/css">
<?php 
include 'config.php';
$id = htmlspecialchars(mysql_real_escape_string($_POST["id"]));
$ip = htmlspecialchars(mysql_real_escape_string($_POST["ip"]));
$agent = htmlspecialchars(mysql_real_escape_string($_POST["agent"]));
$referer = htmlspecialchars(mysql_real_escape_string($_POST["ref"]));

if(!mysql_num_rows(mysql_query("SELECT id FROM " . $tablename . " WHERE id = '$id'"))){
echo "ID not found <a href='admin.php'>Go back!</a>";
} else


if(!($ip != NULL))
{
$result = mysql_query("SELECT id,ip,agent,ref,tm FROM $tablename WHERE id = $id");
while($row = mysql_fetch_array($result))
  {
  echo "<div id='editscreen'><form name='edit' method='post' action='edit.php'>ID: <input name='id' type='text' readonly='readonly' value='". $row['id'] . "'><br /> IP: <input name='ip' type='text' value='" . $row['ip'] . "'><br /> User agent: <input name='agent' type='text' value='" . $row['agent'] . "'><br /> Referer: <input name='ref' type='text' value='" . $row['ref'] . "'><br /> Logged @ " . $row["tm"] . "<br /><input type='submit' name='Submit' value='edit'></form><a href='admin.php'>Go back!</a></div>";
  echo "";
  }
mysql_close($con);
} else {
$result = "update `$tablename` set `ip`='".$ip."', `agent`='".$agent."', `ref`='".$referer."' where id = ".$id;
mysql_query($result) ;
header('Location: admin.php');
}
?>


<?php
}
else
{
header('Location: login.php');
}
?>
